home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2004 April / SGI IRIX 6.5 Applications 2004 April.iso / dist / mozilla.idb / var / netscape / mozilla / chrome / pippki.jar.z / pippki.jar / content / pippki / pref-ciphers.js < prev    next >
Text File  |  2003-11-11  |  3KB  |  100 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3.  *
  4.  * The contents of this file are subject to the Mozilla Public License Version
  5.  * 1.1 (the "License"); you may not use this file except in compliance with
  6.  * the License. You may obtain a copy of the License at
  7.  * http://www.mozilla.org/MPL/
  8.  *
  9.  * Software distributed under the License is distributed on an "AS IS" basis,
  10.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11.  * for the specific language governing rights and limitations under the
  12.  * License.
  13.  *
  14.  * The Original Code is Mozilla Communicator.
  15.  *
  16.  * The Initial Developer of the Original Code is
  17.  * Netscape Communications Corporation.
  18.  * Portions created by the Initial Developer are Copyright (C) 2002
  19.  * the Initial Developer. All Rights Reserved.
  20.  *
  21.  * Contributor(s):
  22.  *   Terry Hayes <thayes@netscape.com>
  23.  *   Kai Engert <kaie@netscape.com>
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  27.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38.  
  39. var gPrefs = null;
  40.  
  41. function onLoad() {
  42.   doSetOKCancel(doOK, doCancel);
  43.  
  44.   // Set checkboxes from prefs
  45.   const nsIPref = Components.interfaces.nsIPref;
  46.  
  47.   gPrefs = Components.classes["@mozilla.org/preferences;1"].getService(nsIPref);
  48.  
  49.   // Enumerate each checkbox on this page and set value
  50.   var prefElements = document.getElementsByAttribute("prefstring", "*");
  51.   for (var i = 0; i < prefElements.length; i++) {
  52.     var element = prefElements[i];
  53.     var prefString = element.getAttribute("prefstring");
  54.     var prefValue = false;
  55.  
  56.     try {
  57.       prefValue = gPrefs.GetBoolPref(prefString);
  58.     } catch(e) { /* Put debug output here */ }
  59.  
  60.     element.setAttribute("checked", prefValue);
  61.     // disable xul element if the pref is locked.
  62.     if (gPrefs.PrefIsLocked(prefString)) {
  63.       element.disabled=true;
  64.     }
  65.   }
  66. }
  67.  
  68. function showInfo(cipher_name) {
  69.   window.openDialog('chrome://pippki/content/cipherinfo.xul', cipher_name,
  70.                     'modal=yes,resizable,chrome');
  71. }
  72.  
  73. function doOK() {
  74.  // Save the prefs
  75.  try {
  76.   // Enumerate each checkbox on this page and save the value
  77.   var prefElements = document.getElementsByAttribute("prefstring", "*");
  78.   for (var i = 0; i < prefElements.length; i++) {
  79.     var element = prefElements[i];
  80.     var prefString = element.getAttribute("prefstring");
  81.     var prefValue = element.getAttribute("checked");
  82.  
  83.  
  84.     if (typeof(prefValue) == "string") {
  85.       prefValue = (prefValue == "true");
  86.     }
  87.  
  88.     gPrefs.SetBoolPref(prefString, prefValue);
  89.   }
  90.  
  91.   gPrefs.savePrefFile(null);
  92.  } catch(e) { }
  93.  
  94.  window.close();
  95. }
  96.  
  97. function doCancel() {
  98.   window.close();
  99. }
  100.